import API from './api';
import http from '../plugin/http';
import type { IChaptersDataModal, IChaptersItemDataModal } from '../type';

const getChapters = async (params: { bookId: string }) => {
    return await http.get(API.CHAPTERS_GETCHAPTERS, { params });
};

const getChapter = async (params: { id: string }) => {
    return await http.get(API.CHAPTERS_GETCHAPTER, { params });
};

const addChapter = async (params: IChaptersDataModal) => {
    return await http.post(API.CHAPTERS_ADD, params)
};

const updatedChapter = async (params: IChaptersItemDataModal) => {
    return await http.post(API.CHAPTERS_UPDATE, params)
};

const changeDirectoryChapter = async (params: { id: string, dropId: string; dropType: string }) => {
    return await http.post(API.CHAPTERS_CHANGE_DIRECTORY, params);
}

export default {
    getChapters,
    getChapter,
    addChapter,
    updatedChapter,
    changeDirectoryChapter,
}